package com.example.demo_test;

import org.jasypt.util.text.BasicTextEncryptor;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;

/**
 * @author zhanghong
 * @date 2021/6/14  0014 23:45
 */
public class test {

    public static void main(String[] args) throws UnsupportedEncodingException {
// 加密
//        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();
//        textEncryptor.setPassword( "password" );
//        String newPassword = textEncryptor.encrypt( "爱你" );
//        System.out.println( newPassword );
//// 解密
//        BasicTextEncryptor textEncryptor2 = new BasicTextEncryptor();
//        textEncryptor2.setPassword( "password" );
//        String oldPassword = textEncryptor2.decrypt( newPassword );
//        System.out.println( oldPassword );
//        System.out.println( "--------------------------" );
//        String Mtext="ninhao!123您好！";
//        Mtext=java.net.URLEncoder.encode(Mtext,"GBK");
//        byte ptext[]=Mtext.getBytes("GBK");//将字符串转换成byte类型数组，实质是各个字符的二进制形式
//        BigInteger m=new BigInteger(ptext);//二进制串转换为一个大整数
//
//        byte[]mt=m.toByteArray();//m为密文的BigInteger类型
//        String str=(new String(mt,"GBK"));
//        str=java.net.URLDecoder.decode(str,"GBK");
//        System.out.println( "爱你" );
//
//
//        System.out.println(str);

    }
}
